//
//  DPNotificationObserver.h
//  UITestingKit
//
//  Created by Ofri Wolfus on 15/03/07.
//  Copyright 2007 Ofri Wolfus. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSNotificationCenter (DPNotificationObserver)

/*!
 * @abstract Waits for a notification to be posted and returns.
 *
 * @discussion In order to accomplish it's goal, a new loop in 
 * the current runloop is started (in the default mode). If no sources
 * are attached to the current runloop, it'll sit idle until the
 * expected notification is received. Other notifications can still be
 * posted to the receiver while waiting in this method.
 * This method returns only after the expected notification is received.
 *
 * @param name The name of the expected notification.
 * @param object The object of the expected notification.
 */
- (void)waitForNotification:(NSString *)name
					 object:(id)object;

/*!
 * @abstract Waits for a notification to be posted and returns.
 *
 * @discussion This method is equivalent to <code>waitForNotification:object:</code>
 * except it returns either if the expected notification has arrived or
 * if the specified timeout has reached.
 *
 * @param name The name of the expected notification.
 * @param object The object of the expected notification.
 * @param sec The number of seconds to wait before timing out.
 *  Any value lower than or equal to zero is ignored, and the method will return
 *  only when the notification is received.
 *
 * @result <code>YES</code> if the notification has been received, <code>NO</code>
 * if the method timed out.
 */
- (BOOL)waitForNotification:(NSString *)name
					 object:(id)object
					timeout:(NSTimeInterval)sec;

@end
